package com.hzhk.happyrent.ui.adapter.viewpager;

import android.content.Context;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import android.support.v4.app.FragmentTransaction;
import android.view.ViewGroup;


import com.hzhk.happyrent.R;
import com.hzhk.happyrent.utils.ListUtils;

import java.util.List;

/**
 * User: hzhk(1097282555@qq.com)
 * Date: 2017/12/01
 * Time: 16:38
 * progject: hzk
 * Describe： ${Describe}
 */
public class ModelPagerAdapter extends FragmentPagerAdapter {
    private FragmentManager fragmentManager;
    private FragmentTransaction mCurTransaction = null;
    private static int[] type=new int[]{R.string.product_pic_info,R.string.product_type_info};
    private List<Fragment> fragments;
    private Context context;
    public ModelPagerAdapter(FragmentManager fm, List<Fragment> fragments,Context context) {
        super(fm);
        this.fragmentManager = fm;
        this.fragments = fragments;
        this.context=context;
    }

    @Override
    public Fragment getItem(int position) {
        return fragments.get(position);
    }

    @Override
    public CharSequence getPageTitle(int position) {
        return context.getString(type[position]);
    }

    @Override
    public int getCount() {
        return !ListUtils.isEmpty(fragments) ? fragments.size() : 0;
    }

    @Override
    public void destroyItem(ViewGroup container, int position, Object object) {
//        super.destroyItem(container, position, object);
    }
}
